package cn.tedu.service.impl;

import cn.tedu.entity.RolesEntity;
import cn.tedu.mapper.RoleMapper;
import cn.tedu.service.RoleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, RolesEntity> implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public IPage<RolesEntity> selectPageExt(String pageCurrent, Integer pageSize, String name) {
        Map<String,String >  params = new HashMap<String,String>();
        params.put("page",pageCurrent+"");
        params.put("limit",pageSize+"");
        QueryWrapper<RolesEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(!StringUtils.isEmpty(name),"name",name);
        
        Page<RolesEntity> page = new Page<RolesEntity>();
        IPage<RolesEntity> iPage = roleMapper.selectPage(page,wrapper);
        return iPage;
    }
}
